<template>
  <div class="envir-monitor">
    <aside class="aside">
      <div class="search-wrap" @click="openDia">
        <img class="img" src="./images/search.png" alt="" />
        <span>搜索</span>
      </div>
      <el-tree
        node-key="id"
        indent="20"
        :data="data"
        :props="defaultProps"
        @node-click="handleNodeClick"
      />
    </aside>
    <main class="main">
      <header class="header">
        <TitleName name="环境温湿度" />
        <el-form :model="formData" size="large" :inline="true">
          <el-form-item label="查询日期:">
            <el-date-picker
              v-model="value1"
              type="date"
              placeholder="请选择日期"
            />
          </el-form-item>
          <el-form-item>
            <el-button class="search" @click="search">查询</el-button>
          </el-form-item>
        </el-form>
      </header>
      <div class="show-data">
        <div class="temperature">
          <img src="./images/temperature.png" alt="" />
          <div class="data">
            <div class="top">
              <div class="name">温度</div>
              <div class="value">--</div>
            </div>
            <div class="line"></div>
            <div class="btm">
              <div class="name">温度</div>
              <div class="value">--</div>
            </div>
          </div>
        </div>
        <div class="water">
          <img src="./images/wateer-logger.png" alt="" />
          <div class="wrap">
            <div class="name">水浸</div>
            <div class="value">--</div>
          </div>
        </div>
        <div class="smog">
          <img src="./images/smog.png" alt="" />
          <div class="wrap">
            <div class="name">烟雾</div>
            <div class="value">--</div>
          </div>
        </div>

        <div class="gate">
          <img src="./images/gate.png" alt="" />
          <div class="data">
            <div class="top">
              <div class="name">门状态</div>
              <div class="value">
                <button>更多</button>
              </div>
            </div>
            <div class="line"></div>
            <div class="btm">
              <div class="small-gate-wrap">
                <img src="./images/small-gate.png" alt="" />
                <span>1#:门:关门</span>
              </div>
              <div class="small-gate-wrap">
                <img src="./images/small-gate.png" alt="" />
                <span>2#:门:关门</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="content">
        <div class="sel-wrap" @click="selPerature">
          <div
            class="temperature"
            :style="{ color: selTemperature == 'temperature' ? '#176FF9' : '' }"
          >
            温度
          </div>
          <div class="line"></div>
          <div
            class="humidity"
            :style="{ color: selTemperature == 'humidity' ? '#176FF9' : '' }"
          >
            湿度
          </div>
        </div>
        <!-- <h3 class="h3">单位（℃）</h3> -->
        <div class="echart-wrap">
          <Echarts v-model:lineColor="selTemperature" />
        </div>
      </div>
    </main>
    <SearchDia v-model:visible="dialogVisible" @serachDigSure="serachDigSure" />
  </div>
</template>
<script setup lang="ts">
import { Upload } from "@element-plus/icons-vue";
import SearchDia from "./component/DiaSearch";
import { ref, reactive } from "vue";
import TitleName from "../../components/TitleName";
import Echarts from "./component/Echarts";
let search = ref("");
let pageSize = ref("10");
let total = ref(111);
let currentPage = ref(1);
let dialogVisible = ref(false);
let selTemperature = ref("humidity");
let value1 = ref("");
let formData = reactive({});
const defaultProps = {
  children: "children",
  label: "label",
};
const selPerature = (e) => {
  let name = e.target.className;

  if (
    (name != "humidity" && name != "temperature") ||
    name == selTemperature.value
  )
    return;
  selTemperature.value = name;
};
const serachDigSure = () => {
  console.log("弹框确认");
};
const data = [
  {
    label: "Level one 1",
    children: [
      {
        label: "Level two 1-1",
        children: [
          {
            label: "Level three 1-1-1",
          },
        ],
      },
    ],
  },
  {
    label: "Level one 2",
    children: [
      {
        label: "Level two 2-1",
        children: [
          {
            label: "Level three 2-1-1",
          },
        ],
      },
      {
        label: "Level two 2-2",
        children: [
          {
            label: "Level three 2-2-1",
          },
        ],
      },
    ],
  },
  {
    label: "Level one 3",
    children: [
      {
        label: "Level two 3-1",
        children: [
          {
            label: "Level three 3-1-1",
          },
        ],
      },
      {
        label: "Level two 3-2",
        children: [
          {
            label: "Level three 3-2-1",
          },
        ],
      },
    ],
  },
];
const handleNodeClick = (data) => {
  console.log(data);
};

const andleSelectionChange = () => {};
const openDia = () => {
  dialogVisible.value = true;
};
</script>
<style lang="scss" scoped>
.envir-monitor {
  padding: 14px 17px 19px 13px;
  display: flex;
  box-sizing: border-box;
  overflow: hidden;
  .aside {
    height: calc(100vh - 19px - 130px);
    width: 272px;
    margin-right: 10px;
    background-color: #fff;
    padding: 31px 0 24px 17px;
    .search-wrap {
      display: flex;
      align-items: center;
      background: #ffffff;
      border: 1px solid #176ff9;
      border-radius: 5px;
      height: 42px;
      width: 239px;
      padding-left: 28px;
      margin-bottom: 24px;
      cursor: pointer;

      span {
        font-weight: 400;
        color: #176ff9;
        font-size: 19px;
        padding-left: 11px;
      }
      .img {
        width: 19px;
        height: 19px;
      }
    }
  }
  .main {
    height: calc(100vh - 19px - 130px);
    width: calc(100vw - 295px - 161px);
    /* background-color: #fff; */
    .header {
      background: #ffffff;
      height: 130px;
      width: 100%;
      padding-top: 22px;
      .el-form {
        padding-top: 26px;
        padding-left: 37px;
        .el-button {
          font-size: 22px;
          font-weight: 400;
          color: #ffffff;
        }
        .search {
          width: 100px;
          height: 42px;
          border-radius: 5px;
          background: #0250f9;
        }
      }
    }
    .show-data {
      width: 100%;
      display: flex;
      justify-content: space-between;
      margin-top: 10px;
      .temperature,
      .water,
      .smog,
      .gate {
        padding: 24px 25px 30px 15px;
        width: 346px;
        height: 122px;
        background: #ffffff;
        box-sizing: border-box;
      }
      .water,
      .smog {
        display: flex;
        align-items: center;
        padding: 24px 25px 30px 15px;
        img {
          width: 75px;
          height: 75px;
        }
        .wrap {
          margin-left: 17px;
          display: flex;
          justify-content: space-between;
          flex-grow: 1;
          .name,
          .value {
            font-size: 23px;
            font-weight: 500;
            color: #333333;
          }
        }
      }
      .temperature {
        padding: 0 25px 0 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        img {
          width: 73px;
          height: 75px;
        }
        .data {
          display: flex;
          flex-direction: column;
          flex-grow: 1;
          margin-left: 18px;
          height: calc(122px - 35px - 12px);
          justify-content: space-between;
          .name,
          .value {
            font-size: 23px;
            font-weight: 500;
            color: #333333;
          }

          .top {
            display: flex;
            justify-content: space-between;
          }
          .line {
            height: 1px;

            border: 0.5px dashed #d2d2d2;
          }
          .btm {
            display: flex;
            justify-content: space-between;
          }
        }
      }

      .gate {
        padding: 0 25px 0 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        img {
          width: 73px;
          height: 75px;
        }
        .data {
          display: flex;
          flex-direction: column;
          flex-grow: 1;
          margin-left: 18px;
          justify-content: space-between;
          .name,
          .value {
            font-size: 23px;
            font-weight: 500;
            color: #333333;
          }
          .value button {
            width: 64px;
            height: 27px;
            background: #0250f9;
            font-size: 17px;
            font-weight: 400;
            color: #ffffff;
          }
          .top {
            display: flex;
            justify-content: space-between;
            margin-bottom: 6px;
          }
          .line {
            height: 1px;
            border: 0.5px dashed #d2d2d2;
          }
          .btm {
            display: flex;
            justify-content: space-between;
            margin-top: 8px;
            .small-gate-wrap {
              display: flex;
              flex-direction: column;
              align-items: center;
              span {
                font-size: 13px;
                font-weight: 500;
                color: #333333;
              }
              img {
                width: 22px;
                height: 26px;
                margin-bottom: 5px;
              }
            }
          }
        }
      }
    }
    .content {
      background: #ffffff;
      margin-top: 10px;
      /* width: ; */
      height: calc(100vh - 19px - 173px - 228px);

      position: relative;
      .sel-wrap {
        width: 245px;
        height: 44px;
        border: 1px solid #cccccc;
        border-radius: 5px;
        padding: 0px 50px 0 36px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-left: 21px;
        position: absolute;
        top: 15px;
        left: 10px;
        z-index: 999;
        .temperature {
          font-size: 20px;
          font-weight: 500;
          color: #333333;
          cursor: pointer;
        }
        .line {
          width: 1px;
          height: 16px;
          background: #cccccc;
        }
        .humidity {
          font-size: 20px;
          font-weight: 500;
          color: #333333;
          cursor: pointer;
        }
      }
      .h3 {
        font-size: 20px;
        font-weight: 500;
        color: #333333;
        margin-left: 49px;
        margin-top: 20px;
        position: absolute;
        top: 60px;
        z-index: 999;
        left: -5px;
      }
      .echart-wrap {
        padding-top: 70px;
        /* height: 300px; */
      }
    }
  }
}
</style>
